var e = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../http/selectionApi")), t = (require("../../utils/tool"), 
new e.default(), getApp());

Page({
    loadTimes: 0,
    params: null,
    timer: null,
    onLoad: function(e) {
        this.params = e, console.info("webview参数：" + JSON.stringify(e));
        var n = "", o = t.globalData.userData ? t.globalData.userData.miniOpenID : null;
        o && (n += "miniOpenID=" + encodeURIComponent(o)), e.fromUrl && (n.length > 0 && (n += "&"), 
        n += "fromUrl=" + encodeURIComponent(e.fromUrl));
        var i = decodeURIComponent(e.url);
        -1 != i.indexOf("?") ? i += "&" : i += "?", i += n, console.info("webview加载：" + i), 
        this.setData({
            url: i
        }), wx.setNavigationBarTitle({
            title: "1983抽盒机"
        });
    },
    onHide: function() {},
    onUnload: function() {
        this.timer && clearInterval(this.timer);
    },
    pageOnError: function(e) {
        console.log(e), t.showToast("网页加载失败");
    },
    pageOnLoad: function(e) {
        this.loadTimes++, 1 == this.loadTimes && this.params.cd && this.countDownTime(this.params.cd);
    },
    countDownTime: function(e) {
        var n = this;
        console.log("countDownTime:", this.params.cd, e), t.showToastLong("浏览".concat(e, "秒，即可完成任务")), 
        this.timer && clearInterval(this.timer), this.timer = setInterval(function() {
            if (--e % 5 == 0 && e > 0 && n.params.cd - e > 2 && t.showToast("剩余".concat(e, "秒")), 
            0 == e) {
                t.showToastLong("倒计时结束，任务已完成！"), clearInterval(n.timer);
                var o = n.getOpenerEventChannel();
                o.emit && o.emit("onCdEnd", {});
            }
        }, 1e3);
    }
});